using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using MBMC.Paths;

namespace MBMC.Dialogs
{
    public partial class NewSky : Form
    {
        //DML TEMPLATE
        /*
            sky_FR - front - 1
            sky_RT - right - 2
            sky_BK - back - 3
            sky_LF - left - 4
            sky_UP - up - 5
            sky_DN - down - 6
            enviro_map - enviroment map - 7
         * **SELECT NAME - 8
         * **COPY FILES - 9
         * **SAVE DML - 10
         */

        string mbfolder;
        int actualposition = 1;
        string currentskyname;

        Paths.Paths p = new MBMC.Paths.Paths();

        public NewSky(string actualmbfolder)
        {
            InitializeComponent();
            mbfolder = actualmbfolder;
        }

        private void NewSky_Load(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            //save sky
            richTextBox2.SaveFile(p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname + "/sky_day.dml", RichTextBoxStreamType.PlainText);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            openFileDialog1.ShowDialog();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            //ena + disa buttons
            if (actualposition == 1)
            {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = true;
                button4.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = false;
                button7.Enabled = false;
                button8.Enabled = false;
                openFileDialog1.Title = "Step 1";
            }
            if (actualposition == 2)
            {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = true;
                button6.Enabled = false;
                button7.Enabled = false;
                button8.Enabled = false;
                openFileDialog1.Title = "Step 2";
            }
            if (actualposition == 3)
            {
                button1.Enabled = false;
                button2.Enabled = true;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = false;
                button7.Enabled = false;
                button8.Enabled = false;
                openFileDialog1.Title = "Step 3";
            }
            if (actualposition == 4)
            {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = true;
                button7.Enabled = false;
                button8.Enabled = false;
                openFileDialog1.Title = "Step 4";
            }
            if (actualposition == 5)
            {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = false;
                button7.Enabled = true;
                button8.Enabled = false;
                openFileDialog1.Title = "Step 5";
            }
            if (actualposition == 6)
            {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = true;
                button5.Enabled = false;
                button6.Enabled = false;
                button7.Enabled = false;
                button8.Enabled = false;
                openFileDialog1.Title = "Step 6";
            }
            if (actualposition == 7)
            {
                button1.Enabled = true;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = false;
                button7.Enabled = false;
                button8.Enabled = false;
                openFileDialog1.Title = "Step 7";
            }
            if (actualposition == 8)
            {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = false;
                button7.Enabled = false;
                button8.Enabled = true;
                textBox1.Enabled = true;
            }
            if (actualposition == 9)
            {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = false;
                button7.Enabled = false;
                button8.Enabled = false;
            }
            if (actualposition == 10)
            {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                button6.Enabled = false;
                button7.Enabled = false;
                button8.Enabled = false;
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            //right
            openFileDialog1.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            //back
            openFileDialog1.ShowDialog();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            //left
            openFileDialog1.ShowDialog();
        }

        private void button7_Click(object sender, EventArgs e)
        {
            //up
            openFileDialog1.ShowDialog();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            //down
            openFileDialog1.ShowDialog();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //enviro
            openFileDialog1.ShowDialog();
        }

        private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            if(openFileDialog1.Title == "Step 1")
            {
                pictureBox5.ImageLocation = openFileDialog1.FileName;
                System.IO.Directory.CreateDirectory(p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname);
                System.IO.File.Copy(openFileDialog1.FileName, p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname + "/sky_front.jpg");
                richTextBox2.Text += "sky_front.jpg";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                actualposition = 2;
            }
            if (openFileDialog1.Title == "Step 2")
            {
                pictureBox3.ImageLocation = openFileDialog1.FileName;
                //System.IO.Directory.CreateDirectory(p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname);
                System.IO.File.Copy(openFileDialog1.FileName, p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname + "/sky_right.jpg");
                richTextBox2.Text += "sky_right.jpg";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                actualposition = 3;
            }
            if (openFileDialog1.Title == "Step 3")
            {
                pictureBox2.ImageLocation = openFileDialog1.FileName;
                System.IO.File.Copy(openFileDialog1.FileName, p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname + "/sky_back.jpg");
                richTextBox2.Text += "sky_back.jpg";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                actualposition = 4;
            }
            if (openFileDialog1.Title == "Step 4")
            {
                pictureBox4.ImageLocation = openFileDialog1.FileName;
                System.IO.File.Copy(openFileDialog1.FileName, p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname + "/sky_left.jpg");
                richTextBox2.Text += "sky_left.jpg";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                actualposition = 5;
            }
            if (openFileDialog1.Title == "Step 5")
            {
                pictureBox6.ImageLocation = openFileDialog1.FileName;
                System.IO.File.Copy(openFileDialog1.FileName, p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname + "/sky_up.jpg");
                richTextBox2.Text += "sky_up.jpg";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                actualposition = 6;
            }
            if (openFileDialog1.Title == "Step 6")
            {
                pictureBox7.ImageLocation = openFileDialog1.FileName;
                System.IO.File.Copy(openFileDialog1.FileName, p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname + "/sky_down.jpg");
                richTextBox2.Text += "sky_down.jpg";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                actualposition = 7;
            }
            if (openFileDialog1.Title == "Step 7")
            {
                pictureBox1.ImageLocation = openFileDialog1.FileName;
                System.IO.File.Copy(openFileDialog1.FileName, p.Vrat_Cestu(mbfolder, MBPaths.FMDSkies) + "/" + currentskyname + "/enviro.jpg");
                richTextBox2.Text += "enviro.jpg";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                richTextBox1.Text += openFileDialog1.FileName + "\n";
                actualposition = 8;
            }
        }

        private void groupBox1_Enter(object sender, EventArgs e)
        {

        }

        private void button9_Click(object sender, EventArgs e)
        {
            currentskyname = textBox2.Text;
            textBox1.Text = textBox2.Text;
            panel1.Hide();
        }
    }
}